

import java.awt.*;

import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.SwingConstants;


import javax.swing.SwingConstants;


public class MainFrame extends JFrame{
	 private static final long serialVersionUID = 1L;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;

	

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainFrame frame = new MainFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public MainFrame() {
		//设置窗口标题
		setTitle("东软商店");
		//设置窗体位置与大小
		setBounds(100, 100, 600, 600);
		//设置关闭操作的事件
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//固定大小
		setSize(400,400);
		//设置窗口的位置为居中显示
		setLocationRelativeTo(null);
		// 创建⼀个 JPanel (div) 容器, 设置当前的容器为

		 JPanel panel = new JPanel();
		 GridBagLayout gbl = new GridBagLayout();
		 panel.setLayout(gbl);
		 
		 // 创建⼀个 Label 标签
		 JLabel lbl = new JLabel("欢迎进入东软商城");
		 lbl.setFont(new Font("宋体", Font.PLAIN, 30));
		 lbl.setHorizontalAlignment(SwingConstants.CENTER);
		 // 创建对lbl的约束布局
		 GridBagConstraints gbc_lbl = new GridBagConstraints();
		 gbc_lbl.fill = GridBagConstraints.BOTH;
		 gbc_lbl.gridx = 0; // 0 列
		 gbc_lbl.gridy = 0; // 0 ⾏
		 gbc_lbl.gridwidth = 3; // 横跨三列
		 gbc_lbl.weightx = 1; // ⽔平权重
		 // 外填充
		 gbc_lbl.insets = new Insets(10, 10, 10, 10);
		 // 将标签添加到panel
		 panel.add(lbl, gbc_lbl);
		 
		 
		 // 创建第⼀个 button 组件
		 JButton viewButton = new JButton("浏览商品");
		 // 创建对viewButton的约束布局
		 GridBagConstraints gbc_viewButton = new
		GridBagConstraints();
		 gbc_viewButton.gridx = 0; // 0 列
		 gbc_viewButton.gridy = 1; // 1 ⾏
		 gbc_viewButton.weightx = 1; // ⽔平权重
		 // 外填充
		 gbc_viewButton.insets = new Insets(5, 10, 5, 5);
		 // 将标签添加到panel
		 panel.add(viewButton, gbc_viewButton);
		 viewButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				LookinggoodsFrame Frame=new LookinggoodsFrame();
				Frame.setVisible(true);
				setVisible(false);
			}
		});
		 
		 // 创建第⼆个 button 组件
		 JButton loginButton = new JButton("用户登录");
		 // 创建对viewButton的约束布局
		 GridBagConstraints gbc_loginButton = new
		GridBagConstraints();
		 gbc_loginButton.gridx = 1; // 1 列
		 gbc_loginButton.gridy = 1; // 1 ⾏
		 gbc_loginButton.weightx = 1; // ⽔平权重
		 // 外填充
		 gbc_loginButton.insets = new Insets(5, 10, 5, 5);
		 // 将标签添加到panel
		 panel.add(loginButton, gbc_loginButton);
		 
		 //给loginButton添加点击事件
		 loginButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				//创建登录frame的对象
			ManagerLoad load=new ManagerLoad();
				//登录显示
				load.setVisible(true);
				//登录不显示
				setVisible(false);
				
			}
		 });
		 
		 // 创建第三个 button 组件
		 JButton registerButton = new JButton("新会员注册");
		 // 创建对viewButton的约束布局
		 GridBagConstraints gbc_registerButton = new
		GridBagConstraints();
		 gbc_registerButton.gridx = 2; // 2 列
		 gbc_registerButton.gridy = 1; // 1 ⾏
		 gbc_registerButton.weightx = 1; // ⽔平权重
		 // 外填充
		 gbc_loginButton.insets = new Insets(5, 10, 5, 5);
		 // 将标签添加到panel
		 panel.add(registerButton, gbc_registerButton);
		 
		 registerButton.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					// TODO Auto-generated method stub
					//创建登录frame的对象
			RegisterMenberFrame load=new RegisterMenberFrame();
					//登录显示
					load.setVisible(true);
					//登录不显示
					setVisible(false);
					
				}
			 });
		 
		 
		 
		 
		 
		 // 设置当的JFrame 的 Panel内容为创建的
		 getContentPane().add(panel);
	}
}